from datetime import datetime
from typing import Optional, List

from pydantic import BaseModel, Field


# 添加分页相关的模型
class Pagination(BaseModel):
    page: int = Field(1, ge=1, description="页码")
    page_size: int = Field(10, ge=1, le=100, description="每页数量")
    total: int = Field(0, description="总记录数")


class Token(BaseModel):
    access_token: str
    token_type: str


class TokenData(BaseModel):
    username: Optional[str] = None


class UserCreate(BaseModel):
    username: str
    password: str


class UserUpdate(BaseModel):
    password: Optional[str] = None
    is_active: Optional[bool] = None


# 更新UserResponse模型
class UserResponse(BaseModel):
    id: str
    username: str
    is_active: bool


# 更新UserListResponse模型
class UserListResponse(BaseModel):
    data: List[UserResponse]
    pagination: Pagination


class FaceRegisterResponse(BaseModel):
    status: str
    user_id: int
    image_url: str


class FaceRecognizeResult(BaseModel):
    user_id: int
    user_name: str
    similarity: float
    image_url: Optional[str] = None
    result_url: Optional[str] = None


class FaceRecordResponse(BaseModel):
    id: str
    user_id: int
    user_name: str
    image_url: str
    created_at: datetime
    updated_at: datetime
    created_user: str
    updated_user: str


class FaceRecordListResponse(BaseModel):
    data: List[FaceRecordResponse]
    pagination: Pagination
